package com.cat.DataStructure04;

import java.util.HashSet;
import java.util.Set;

/**
 * @author 曲大人的喵
 * @description https://leetcode.cn/problems/number-of-unique-xor-triplets-ii/
 * @create 2025/11/29 11:23
 * @since JDK17
 */

public class Solution24 {
    Set<Integer> f(Set<Integer> nums, int[] arr) {
        Set<Integer> t = new HashSet<>();
        for (var x : nums) {
            for (var y : arr) {
                t.add(x ^ y);
            }
        }
        return t;
    }
    public int uniqueXorTriplets(int[] nums) {
        Set<Integer> set = new HashSet<>();
        for (var x : nums) {
            set.add(x);
        }
        nums = new int[set.size()];
        int i = 0;
        for (var x : set) {
            nums[i++] = x;
        }
        set = f(set, nums);
        set = f(set, nums);
        return set.size();
    }
}
